package com.sean.findme.near;

import java.util.HashMap;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

import com.sean.findme.FmActivityInfo;
import com.sean.findme.FmActivityMgrCtrller;
import com.sean.findme.R;
import com.sean.findme.dbentrys.ShopInfos;

public class NearActivityGroup extends ActivityGroup{

	LinearLayout container = null;
	NearActivityManager nearActivityMgr = null;
	ShopInfos shopInfos = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.groupactivity);
		
		shopInfos = new ShopInfos();
		
		nearActivityMgr = new NearActivityManager(this);
		FmActivityMgrCtrller.getInstance(null).setCurActivityMgr(getResources().getString(R.string.near_tab));
		FmActivityMgrCtrller.getInstance(null).registerActivityMgr(getResources().getString(R.string.near_tab), nearActivityMgr);
		
		container = (LinearLayout)findViewById(R.id.group_activity_layout);
		container.removeAllViews();
		
		Intent intent = new Intent( NearActivityGroup.this, NearActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		
		nearActivityMgr.configFirstActivity(this);
		
		Window subActivity = this.getLocalActivityManager().startActivity("NearActivity", intent);
		View view = subActivity.getDecorView();
		container.addView(view);
		LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)view.getLayoutParams();
		params.width = LayoutParams.FILL_PARENT;
		params.height = LayoutParams.FILL_PARENT;
		view.setLayoutParams(params);
		
		
	}
	@Override
	public void onBackPressed() {
		if( FmActivityMgrCtrller.getInstance(null).getCurActivityMgr().getListActivityInfo().size() <= 1 )
			super.onBackPressed();
		else
		{
			FmActivityMgrCtrller.getInstance(null).getCurActivityMgr().getListActivityInfo().pop().getFromCls();;
			FmActivityInfo info = NearActivityManager.getInstance().getListActivityInfo().peek();
			FmActivityMgrCtrller.getInstance(null).getCurActivityMgr().JmpActivity(this.getCurrentActivity().getBaseContext(), info.getFromCls(), info.getActivityGroup(), info.getMap(),false);
		}
	}
	
	
	
	

}
